package cn.com.yusys.yusp.mobile.web.rest;

import cn.com.yusys.yusp.admin.Utils.IDUtils;
import cn.com.yusys.yusp.commons.web.rest.dto.ResultDto;
import cn.com.yusys.yusp.mobile.service.MyGridService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/mobile/myGrid")
public class MyGridResource {

    @Resource
    MyGridService myGridService;

    @PostMapping("/insertCustomer")
    public ResultDto<Integer> insertCustomer(@RequestBody Map map) {
        map.put("custNo", IDUtils.getGuid());
        int state = myGridService.insertCustomer(map);
        if (state==0){
            return new ResultDto<>(null);
        }
        return new ResultDto<>(state);
    }

    @PostMapping("/insertMerchant")
    public ResultDto<Integer> insertMerchant(@RequestBody Map map) {
            map.put("id", IDUtils.getGuid());
            return new ResultDto<>(myGridService.insertMerchant(map));
    }

    @PostMapping("/updateMerchant")
    public ResultDto<Integer> updateMerchant(@RequestBody Map map) {
            return new ResultDto<>(myGridService.updateMerchant(map));
    }

}
